package com.CI.Login.Business
{
	import com.CI.Login.VO.LoginVO;
	import com.CI.Login.VO.LogoutVO;
	
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	
	public class LogDelegate
	{
		protected var responder : Responder;
		
		public function LogDelegate(responder : Responder)
		{
			this.responder = responder;
		}
		
		public function sendObject(obj : Object) : void
		{   
			var params : Object = new Object();
			var service : HTTPService;
			var token : AsyncToken;
			var responder:mx.rpc.Responder;
			
			if(obj is LoginVO)
			{
				var login : LoginVO = new LoginVO();
				login = obj as LoginVO;
				
				params.action = 'login';
				params.email = login.emailUser;
				params.password = login.passUser;
				
				service = ServiceLocator.getInstance().getHTTPService("login");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Log_onResult, Log_onFault);
				token.addResponder(responder);
			}
			else
			{
				var logout : LogoutVO = new LogoutVO();
				logout = obj as LogoutVO;
				
				params.action = 'logout';
				params.email = logout.emailUser;
				
				service = ServiceLocator.getInstance().getHTTPService("logoutt");
		    	
		    	token = service.send(params);
				responder = new mx.rpc.Responder(Log_onResult, Log_onFault);
				token.addResponder(responder);
			}
		}
		
		protected function Log_onResult(event : ResultEvent) : void
		{
			
		}
		
		protected function Log_onFault(event : FaultEvent) : void
		{
		
		}
	}
}